<template>
  <div class="route-detail">
    <div class="title">
      <span> 2024-04-14 </span>
      <el-icon @click="handleClose"><Close /></el-icon>
    </div>
    <div class="content">
      <div
        class="content-item"
        :class="{ active: current === item.pkid }"
        v-for="(item, index) of routeList"
        :key="index"
      >
        <div class="left">
          <div class="left-circle">{{ index + 1 }}</div>
          <div class="left-line"></div>
        </div>
        <div class="right">
          <span class="right-address">{{ item.address }}</span>
          <span class="right-date">{{ item.date }}</span>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup>
import { ref } from 'vue'
import { Close } from '@element-plus/icons-vue'

const props = defineProps({
  current: {
    type: String,
    default: '',
  },
})
const routeList = ref([
  {
    pkid: '1',
    address: '园区大门',
    date: '2024-01-08 12:56:20',
  },
  {
    pkid: '2',
    address: '园区大门',
    date: '2024-01-08 14:26:40',
  },
  {
    pkid: '3',
    address: '园区大门',
    date: '2024-01-08 15:12:10',
  },
  {
    pkid: '4',
    address: '园区大门',
    date: '2024-01-08 17:26:30',
  },
  {
    pkid: '5',
    address: '园区大门',
    date: '2024-01-08 17:26:30',
  },
])

const emit = defineEmits(['close'])
const handleClose = () => {
  emit('close')
}
</script>
<style lang="scss" scoped>
.route-detail {
  width: 306px;
  height: 648px;
  background: #ffffff;
  box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
  border-radius: 4px;
  position: absolute;
  top: 20px;
  right: 20px;
  .title {
    width: 100%;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
    padding: 0 20px;
    font-weight: 500;
    font-size: 14px;
    color: #333333;
    border-bottom: 1px solid #d5deed;
    .el-icon {
      cursor: pointer;
    }
  }
  .content {
    width: 100%;
    height: calc(100% - 50px);
    overflow-y: auto;
    box-sizing: border-box;
    padding: 20px;
    &-item {
      display: flex;
      align-items: flex-start;
      justify-content: flex-start;
      &:last-child {
        .left-line {
          display: none;
        }
      }
      &.active {
        .left-circle {
          background: #eb8a00;
          border: 1px solid #eb8a00;
          color: #fff;
        }
        .right-address {
          color: #eb8a00;
        }
        .right-date {
          color: #eb8a00;
        }
      }
      .left {
        width: 22px;
        margin-right: 20px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        &-circle {
          width: 22px;
          height: 22px;
          background: #f2f5fa;
          border-radius: 50%;
          border: 1px solid #d9e1ef;
          display: flex;
          align-items: center;
          justify-content: center;
          font-weight: 400;
          font-size: 14px;
          color: #333333;
        }
        &-line {
          width: 1px;
          min-height: 73px;
          background: #d5deed;
          border-radius: 0px;
        }
      }
      .right {
        width: calc(100% - 42px);
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        &-address {
          font-weight: 400;
          font-size: 14px;
          color: #333333;
          margin-bottom: 10px;
        }
        &-date {
          font-weight: 400;
          font-size: 14px;
          color: #757575;
          margin-bottom: 10px;
        }
      }
    }
  }
}
</style>
